<script>

$(document).ready(function() {

	
	$("#validatebutton").click(function () {
		
		var password = $("#password").val();
		var key = $("#key").val();
		$.ajax({
		    type: 'POST',
		    url: context+'user/saveprofil',
		    dataType: 'json',
		    async: false,
		    data:{'password':password,'key':key},
		    success: function(data){
			    if(data['success'])
			    {
			    	$(location).attr('href',context+'home');
			    }
			    else{
			    	 $("#error span").html(data['error']);
				 }
		    },
		    error: function(xhr, status, thrown){
		    	 $("#error span").html(xhr.responseText);
		    }
		});
		return false;
	});


	$("#friendfacebooklink").click(function () {
		$.ajax({
		    type: 'POST',
		    url: context+'user/facebookfriend',
		    dataType: 'json',
		    async: true,
		    success: function(data){
			    if(data['success'])
			    {
			    	var htmltext="";
				    var facebookfriends= data['friends'];
				    alert(facebookfriends['data'].length)
				    for ( var i = 0; i < facebookfriends['data'].length; i++) {
				    	facebookfriend = facebookfriends['data'][i];
				    	htmltext="<img src='https://graph.facebook.com/" +facebookfriend['id']+ "/picture' title='" +facebookfriend['name']+ "' /> "+facebookfriend['name']+"<br>";
				    	$("#friendfacebook_block span").append(htmltext);
					}
				    
			    }
			    else{
			    	 $("#error span").html(data['error']);
				 }
		    },
		    error: function(xhr, status, thrown){
		    	 $("#error span").html(xhr.responseText);
		    }
		});
		return false;
	});


	$("#facebookinvite").click(function () {
	
		FacebookInviteFriends();
		return false;
	});

});
	

</script>
 <?php
   $user = $this->identity();
 ?>
                            
<div class="hero-unit">

<div>

<?php echo $user->firstname." ";  echo $user->lastname?>
<br>
Your account are successfull validate. 
<br>
We need additional information .
<br>
<div id="error">
     <span></span>
  </div>
   <div>
     phone number (e: 0033 6 38 xx xx xx)
      <input id="phone" type="text" value="" />
  </div>
  <div>
     profie picture
      <input id="photo" type="file" value="" />
  </div>
   <div>
     Occupation
      <input id="occupation" type="txt" value="" />
  </div>
   <div>
     About you
      <textarea id="aboutme"  value="" > </textarea>
  </div>
  <input id="key" type="hidden" value="<?php echo $user->keyConfirm?>" />
</div>
<button id="validatebutton">Update profil</button>
<br>

<a id='editlink' href="<?php echo $this->url('user',array('action' => 'edit')) ?>"> edit user </a>
</div>

<a id='facebookinvite' href='#'> 
Facebook Invite Friends Link
</a>

<br>

<a id='friendfacebooklink' href=""> Friends facebook </a>
 <div id='friendfacebook_block'>
       <span></span>
 </div>
 </div>

<div class="row">
</div>
